var num = 0;
var form;

jQuery(function () {
	layui.use(['layer', 'form'], function () {
		form = layui.form();
		init();
	});
});
function init() {
	$("#btn").click(next);
	getSkuProductById(params()["skuId"])
}
function getSkuProductById(id) {
	$.ajax({
		url:server_url+'/rest/product/getSkuProductInfo.do',
		type:'post',
		async:false,
		data:{id:id,ran:Math.random()},
		success:function(data){
			if(data.retCode=="0000"){
				$("#price").val(data.data.price);
				$("#overPlusNum").val(data.data.overPlusNum);
				$("#remark").val(data.data.remark);
				$("#id").val(data.data.id);
			}else{
				easyDialog.open({
					container : {
						header : '提示',
						content : data.retMsg
					},
					autoClose : 2000
				});
			}
		}
	});
}
var b = false;
function next() {
	var price = $("#price").val();
	var overPlusNum = $("#overPlusNum").val();
	if (price == "") {
		easyAlert("请输入价格！");
		return false;
	}
	if (!isPriceNumber(price)) {
		easyAlert("格式不正确！请输入正确的价格格式！");
		return false;
	}
	if (overPlusNum == "") {
		easyAlert("请输入库存！");
		return false;
	}
	if(b){
		return;
	}
	b = true;
	var jsonObj = [];
	jsonObj.push({name:"price",value:price});
	jsonObj.push({name:"overPlusNum",value:overPlusNum});
	jsonObj.push({name:"remark",value:remark});
	jsonObj.push({name:"id",value:$("#id").val()});
	$.ajax({
		url:server_url+'/rest/product/skuProductEdit.do?ran='+Math.random(),
		async:false,
		type:'post',
		data:jsonObj,
		//contentType:'application/x-www-form-urlencoded; charset=utf-8',
		error:function(){
			easyAlert("修改失败！");
		},
		success:function(data){
			//alert(JSON.stringify(data));
			easyAlert("修改成功！");
			window.location.href = "/LianniuWeb//skuProductList.do";
		}
	});
}

